
Array.prototype.maximo = function() {
var max = this[0];
var len = this.length;
for (var i = 1; i < len; i++) if (this[i] > max) max = this[i];
return max;
}




function grafica_piramide1(pos_genX, pos_genY, tope, grosor, stepscala, grps_serie, tit_gprs, serie1, tit_serie1, color_s1, serie2, tit_serie2, color_s2) {
var cant_grps = serie1.length;
var ancho = (tope * 2)+40;
var maximo = 100;
if (serie1.maximo() > serie2.maximo()) maximo = serie1.maximo();
if (serie2.maximo() > serie1.maximo()) maximo = serie2.maximo();


for (i=0;i<cant_grps;i++){
valor1 = serie1[i]*tope/maximo;
valor2 = (serie2[i]*tope/maximo);
var t = paper.text(pos_genX+40, (pos_genY+(grosor*i)+(grosor/2)), grps_serie[i]);t.attr("font-size", "14");

var c = paper.rect((pos_genX + tope + 100), (pos_genY+(grosor*i)), valor1, grosor/3); c.attr("fill", "90-"+color_s1+"-#000"); c.attr("stroke-width", "0"); 
var c = paper.rect((pos_genX + tope + 100), (pos_genY+(grosor*i)+(grosor/3)), valor1, 1); c.attr("fill", "90-#000-"+color_s1); c.attr("stroke-width", "0"); c.animate({height:grosor*2/3}, 1000);


var c2 = paper.rect((pos_genX + tope + 100)-valor2, (pos_genY+(grosor*i)), valor2, grosor/3); c2.attr("fill", "90-"+color_s2+"-#000");c2.attr("stroke-width", "0");
var c2 = paper.rect((pos_genX + tope + 100)-valor2, (pos_genY+(grosor*i)+(grosor/3)), valor2, 1); c2.attr("fill", "90-#000-"+color_s2);c2.attr("stroke-width", "0"); c2.animate({height:grosor*2/3}, 1000);
}

var t = paper.text(pos_genX, pos_genY+((grosor*(i*1))/2), tit_gprs);t.attr("font-size", "14"); t.attr("rotation", "270");

var ypos = pos_genY+((grosor*(i*1))+8);

for (i=0; i<=tope; i=i+stepscala){
var labelvalor = i*maximo/tope;
var t = paper.text((pos_genX + tope + 100)+i, (pos_genY-20)+(grosor * (cant_grps+2))+10, labelvalor); 
var t = paper.text((pos_genX + tope + 100)-i, (pos_genY-20)+(grosor * (cant_grps+2))+10, labelvalor);
var l = paper.rect((pos_genX + tope + 100)+i, (pos_genY-20), 0.2, grosor * (cant_grps+2)); l.attr("stroke-width", "0.2"); l.toBack(); 
var l = paper.rect((pos_genX + tope + 100)-i, (pos_genY-20), 0.2, grosor * (cant_grps+2)); l.attr("stroke-width", "0.2"); l.toBack(); 
}

var t = paper.text((pos_genX + 80)+(ancho/3), ypos+(grosor*3), tit_serie2);t.attr("font-size", "14");
var t = paper.text((pos_genX + 80)+(ancho*2/3), ypos+(grosor*3), tit_serie1);t.attr("font-size", "14");

var fondo = paper.rect((pos_genX + 80), (pos_genY-20), ancho, grosor * (cant_grps+2)); 
fondo.attr("fill", "90-#fff-#ffffcc"); 

fondo.toBack(); 

}

